/**
 * Candidate number: 35834
 * "Action may not always bring happiness; but there is no happiness without action."
 *      —Benjamin Disraeli
 */
package tv.starfu.components;

import com.artemis.Component;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;

/**
 * the *MOVEMENT CONTROLLER of TRANSFORM DREAMS*
 * Add movements to this, **try and get the quaternion working so you can use slerp **
 * @author nia radical
 */
public class FutureTransform extends Component {
    
    public Quaternion qRotator;
    
    // See Artificial Intelligence for Games p87
    public Vector3f velocity;
    public Vector3f position;
    public float orientation;
    public float rotation;
    
    public Vector3f linearSteering;
    public float angularSteering;
    
    public FutureTransform() {
        velocity = new Vector3f();
        position = new Vector3f();
        orientation = 0f;
        rotation    = 0f;
        
        qRotator    = new Quaternion().fromAngleNormalAxis(rotation, new Vector3f(1,0,0).normalize());

    }  
    
    /*
     * If the character is stationary, it faces either a pre- set direction or the last 
     * direction it was moving in. If its movement algorithm returns a target velocity, 
     * then that is used to set its orientation.
     */
    public void newOrientation(float currentOrientation, Vector3f currentPosition) {
        if(velocity.length() > 0) {
            orientation = (float)Math.atan2(-currentPosition.x, currentPosition.z);
        }
    }
}
